//
//  WeiboAnnotation.m
//  Custom_Weibo
//
//  Created by LEO on 12/19/15.
//  Copyright © 2015 Leo_Lei. All rights reserved.
//

#import "WeiboAnnotation.h"

@implementation WeiboAnnotation

- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate {
    _coordinate = newCoordinate;
}


- (void)setWeiboModel:(WeiboModel *)weiboModel {
    if (_weiboModel != weiboModel) {
        _weiboModel = weiboModel;
        
        // Get the coordinate through weibo model.
        NSDictionary *geo = weiboModel.geo;
        NSArray *coordinates = [geo objectForKey:@"coordinates"];
        if (coordinates.count >= 2) {
            NSNumber *latitude = coordinates[0];
            NSNumber *longitude = coordinates[1];
            _coordinate = CLLocationCoordinate2DMake([latitude doubleValue],
                                                     [longitude doubleValue]);
        }
    }
}

@end
